package BinarySearch;

public class singleNonDuplicate {
    public int singleNonDuplicate(int[] nums) {
        int l = 0;
        int r = nums.length - 1;
        int middle = 0;
        while (l < r) {
            middle = l + (r - l) / 2;
            if (middle % 2 == 1) middle--;
            if (nums[middle] == nums[middle + 1]) {
                l = middle + 2;
            } else {
                r = middle;
            }
        }
        return nums[l];
    }
}
